package cn.tedu.boot.ers.controller;

import cn.tedu.boot.ers.pojo.dto.DishesInsertDTO;
import cn.tedu.boot.ers.service.IDishesService;
import cn.tedu.boot.ers.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dishes")
@Api(tags = "点菜模块")
public class DishesController {
    @Autowired
    private IDishesService dishesService;

    @PostMapping("/add")
    @ApiOperation("加菜")
    public JsonResult<Void> add(DishesInsertDTO dishesInsertDTO) {
        dishesService.insert(dishesInsertDTO);
        return JsonResult.ok();
    }

    @PostMapping("/delete")
    @ApiOperation("减菜")
    public JsonResult<Void> delete(Long productId, Long userId) {
        dishesService.delete(productId, userId);
        return JsonResult.ok();
    }
}
